const express = require('express') // 引入express
const Mock = require('mockjs') // 引入mock

let app = express()


// 解决跨域
app.use(function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*')
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS')
    res.header('Access-Control-Allow-Headers', 'X-Requested-With')
    res.header('Access-Control-Allow-Headers', 'Content-Type')
    next()
})
// 获取零售户信息
app.use('/mockapi/test', function (req, res) {
    console.log('mockAPI截取的数据了')
    console.log(req)
    res.json(Mock.mock({
        'code': 0,
        'msg': '执行成功'
    }))
})

app.listen('8090', () => {
    console.log('监听端口 8090')
    //   setTimeout(()=>{//执行}, 1000)
})

